﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        $("#txtSchoolType").bindSelect({
            url: "/SystemManage/ItemsData/GetSelectJson",
            param: { enCode: "SchoolType" }
        });
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/Class/GetGridJson",
            height: $(window).height() - 96,
            colModel: [
                { label: "学校主键", name: "SchoolId", hidden: true, key: true },
                { label: "年级主键", name: "ClassId", hidden: true, key: true },
                { label: '学校名称', name: 'SchoolName', width: 250, align: 'left' },
                {
                    label: '年级类型', name: 'SchoolType', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["SchoolType"][cellvalue] == undefined ? "" : top.clients.dataItems["SchoolType"][cellvalue]
                    }
                },
                {
                    label: '年级类型', name: 'Class', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["Class"][cellvalue] == undefined ? "" : top.clients.dataItems["Class"][cellvalue]
                    }
                },
                { label: '年级学位总数', name: 'ClassFreeTotalAmount', width: 150, align: 'left' },
                @*{ label: '年级学位剩余数', name: 'ClassFreeAmount', width: 150, align: 'left' },
                { label: '备注', name: 'Content', width: 200, align: 'center' },
                @*{ label: '排序号', name: 'SortId', width: 80, align: 'left' },*@
                {
                    label: "有效状态", name: "isEnable", width: 60, align: "left",
                    formatter: function (cellvalue) {
                        return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                    }
                },
            ],
            pager: "#gridPager",
            sortname: 'SortId asc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { SchoolType: $("#txtSchoolType").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "新增学位",
            url: "/Gas/Class/Form",
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_update() {
        var keyValue = $("#gridList").jqGridRowValue().ClassId;
        if (keyValue == null || keyValue == "") {
            alert("请选择想要更新的学校");
            return;
        }
        $.modalOpen({
            id: "Update",
            title: "信息修改",
            url: "/Gas/Class/Form?keyValue=" + keyValue,
            width: "550px",
            height: "570px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();//提交表单
            }
        });
    }
    function btn_delete() {
        $.deleteForm({
            url: "/Gas/Class/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().ClassId },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_generate() {
        $.submitForm({
            url: "/Gas/Class/GenerateForm",
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;添加学位</a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_generate()"><i class="fa fa-plus"></i>&nbsp;生成学位</a>
        </div>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" onclick="btn_update()"><i class="fa fa-pencil-square-o"></i>修改</a></li>
                <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <select id="txtSchoolType" class="form-control" style="width:150px"></select>
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>